package com.milk.web.config;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.milk.ceshi.Ceshi1;
import com.milk.ceshi.Ceshi2;
import com.milk.model.entity.admin.Admin;
import com.milk.web.interceptor.AdminInterceptor;
import com.milk.web.interceptor.UserInterceptor;

@Configuration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter{
	
	
	@Resource
	private AdminInterceptor adminInterceptor;
	@Resource
	private UserInterceptor userInterceptor;
	
	private static String[] adminInterceptorExcludePath = {"/manager/admin/login.do","/manager/admin/logout.do"};
	
	private static String[] userInterceptorExcludePath = {"/user/login.do","/user/logout.do"};
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//registry.addInterceptor(adminInterceptor).addPathPatterns("/manager/**").excludePathPatterns(adminInterceptorExcludePath);
		registry.addInterceptor(userInterceptor).addPathPatterns("/user/**").excludePathPatterns(userInterceptorExcludePath);
		super.addInterceptors(registry);
	}
	
	@Override
	public void configurePathMatch(PathMatchConfigurer configurer) {
		configurer.setUseSuffixPatternMatch(false).setUseTrailingSlashMatch(false);
		super.configurePathMatch(configurer);
	}
}
